***********************************************
***** Pandora's Rules in the Laboratory  ******
***********************************************

** Table 5 - Reactivity parameter

**  Reactivity parameter is calculated by extracting the beta coefficients for every subject
**  after regressing openfirst with the potential content of the safe box.
**  After running each regression, we copy the corresponding beta coefficients (1st column of data) to a new file: T5.dta 


**input file: Full.dta


** change working directory: 
cd "..."


** Treatment 0  - All Periods
clear all
use "Main.dta"
statsby  _b , by(ID2) : regress openfirst pos2 if treatment ==0
keep _b_pos2
rename _b_pos2 reactivityfullt0
save a1.dta, replace

** Treatment 1  - All Periods
clear all
use "Main.dta"
statsby  _b , by(ID2) : regress openfirst pos2 if treatment ==1
keep _b_pos2
rename _b_pos2 reactivityfullt1
save a2.dta, replace

** Treatment 0  - Half Periods
clear all
use "Main.dta"
statsby  _b , by(ID2) : regress openfirst pos2 if treatment ==0 & Period>50
keep _b_pos2
rename _b_pos2 reactivityhalft0
save a3.dta, replace

** Treatment 1  - Half Periods
clear all
use "Main.dta"
statsby  _b , by(ID2) : regress openfirst pos2 if treatment ==1 & Period>50
keep _b_pos2
rename _b_pos2 reactivityhalft1
save a4.dta, replace

clear all
use a1.dta, clear
merge 1:1 _n using "a2.dta", nogenerate
merge 1:1 _n using "a3.dta", nogenerate
merge 1:1 _n using "a4.dta", nogenerate

save T5.dta, replace

******************************************************************************
******************************************************************************

use "T5.dta", clear


*t-test
ttest reactivityfullt0    = reactivityfullt1
ttest reactivityhalft0    = reactivityhalft1

*Wilcoxon test
signrank reactivityfullt0 = reactivityfullt1
signrank reactivityhalft0 = reactivityhalft1

*Sign rank test
signtest reactivityfullt0 = reactivityfullt1
signtest reactivityhalft0 = reactivityhalft1


************ end of Do file ************** 
